$(function () {
    layui.use(['table'],function () {
        var table = layui.table;
        table.render({
            elem:'#LAY_table_admin',
            url:'/pages/back/admin/listSplit',
            toolbar: '#toolbarDemo',//开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports', 'print'],
            page:true,
            limit:10,
            cols:[[
                {field:'aid',title:'ID',sort:true},
                {field:'password',title:'密码'},
                {field:'name',title:'姓名',sort:true},
                {field: 'lastdate', title: '上次登录日期',templet:"<div>{{layui.util.toDateString(d.lastdate,'yyyy-MM-dd HH:mm:ss')}}</div>",sort:true}
            ]],
            id: 'testReload'
        })
        var $ = layui.$, active = {
            reload: function(){
                var name = $('#demoReload').serialize();

                //执行重载
                table.reload('testReload', {
                    url:'/pages/back/Admin/findByName?'+name,
                    where: {
                        key: {
                            name: name
                        }
                    },
                });
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    })
})